package com.pan.structual.flyweight.utils;

import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;

public enum MyFrameUtils {

    INSTANCE;

    public void show(Image image){
        BufferedImage bufferedImage = (BufferedImage) image;

        JLabel label = new JLabel(new ImageIcon(image));

        JFrame frame = new JFrame("show");
        frame.setDefaultCloseOperation(3);
        frame.add(label);
//        why?为啥没效果
//        int imageWidth = bufferedImage.getWidth();
//        int imageHeight = bufferedImage.getHeight();
//        frame.setSize(imageWidth,imageHeight);
        frame.pack();//
        frame.setVisible(true);

    }

}
